<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Bomberman:  Fichier source de /home/ph3w/Bureau/lif7-bomberman/ClientServer/Client/class_client.h</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Généré par Doxygen 1.7.1 -->
<script type="text/javascript">
function hasClass(ele,cls) {
  return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}

function addClass(ele,cls) {
  if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}

function removeClass(ele,cls) {
  if (hasClass(ele,cls)) {
    var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
    ele.className=ele.className.replace(reg,' ');
  }
}

function toggleVisibility(linkObj) {
 var base = linkObj.getAttribute('id');
 var summary = document.getElementById(base + '-summary');
 var content = document.getElementById(base + '-content');
 var trigger = document.getElementById(base + '-trigger');
 if ( hasClass(linkObj,'closed') ) {
   summary.style.display = 'none';
   content.style.display = 'block';
   trigger.src = 'open.png';
   removeClass(linkObj,'closed');
   addClass(linkObj,'opened');
 } else if ( hasClass(linkObj,'opened') ) {
   summary.style.display = 'block';
   content.style.display = 'none';
   trigger.src = 'closed.png';
   removeClass(linkObj,'opened');
   addClass(linkObj,'closed');
 }
 return false;
}
</script>
<div class="header">
  <div class="headertitle">
<h1>/home/ph3w/Bureau/lif7-bomberman/ClientServer/Client/class_client.h</h1>  </div>
</div>
<div class="contents">
<a href="class__client_8h.html">Aller à la documentation de ce fichier.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CLASS_CLIENT_h</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CLASS_CLIENT_h</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &quot;../class_BaseClientServer.h&quot;</span>
<a name="l00005"></a>00005 <span class="comment"></span>
<a name="l00006"></a>00006 <span class="comment">/*!</span>
<a name="l00007"></a>00007 <span class="comment">* @class client</span>
<a name="l00008"></a>00008 <span class="comment">* @brief Cette class permet de gérer facilement un client.</span>
<a name="l00009"></a>00009 <span class="comment">*</span>
<a name="l00010"></a>00010 <span class="comment">* Exemple d&#39;utilisation</span>
<a name="l00011"></a>00011 <span class="comment">* @code</span>
<a name="l00012"></a>00012 <span class="comment">*   SOCKET s;</span>
<a name="l00013"></a>00013 <span class="comment">*   char buffer[20];</span>
<a name="l00014"></a>00014 <span class="comment">*</span>
<a name="l00015"></a>00015 <span class="comment">*   client cli;</span>
<a name="l00016"></a>00016 <span class="comment">*   cli.setPort(1234);</span>
<a name="l00017"></a>00017 <span class="comment">*   cli.setServerAdress(&quot;127.0.0.1&quot;);</span>
<a name="l00018"></a>00018 <span class="comment">*</span>
<a name="l00019"></a>00019 <span class="comment">*   if( cli.connection() == 0 )// Connection et Si pas de connection =&gt; exit</span>
<a name="l00020"></a>00020 <span class="comment">*       exit(1);</span>
<a name="l00021"></a>00021 <span class="comment">*</span>
<a name="l00022"></a>00022 <span class="comment">*   do {</span>
<a name="l00023"></a>00023 <span class="comment">*       if( cli.lookupConnection() ){// A faire en 1er !</span>
<a name="l00024"></a>00024 <span class="comment">*           memset(buffer, 0, 20);// On vide le buffer</span>
<a name="l00025"></a>00025 <span class="comment">*           if( cli.readServer(buffer, 20) ){</span>
<a name="l00026"></a>00026 <span class="comment">*               printf(&quot;%s&quot;, buffer);</span>
<a name="l00027"></a>00027 <span class="comment">*           }else{</span>
<a name="l00028"></a>00028 <span class="comment">*               break;// On a été déconnecté !</span>
<a name="l00029"></a>00029 <span class="comment">*           }</span>
<a name="l00030"></a>00030 <span class="comment">*       }</span>
<a name="l00031"></a>00031 <span class="comment">*</span>
<a name="l00032"></a>00032 <span class="comment">*   }while( cli.is_connected() == 1 );// On reste tant que l&#39;on est connecté</span>
<a name="l00033"></a>00033 <span class="comment">* @endcode</span>
<a name="l00034"></a>00034 <span class="comment">*/</span>
<a name="l00035"></a><a class="code" href="classclient.html">00035</a> <span class="keyword">class </span><a class="code" href="classclient.html" title="Cette class permet de gérer facilement un client.">client</a> : <span class="keyword">public</span> <a class="code" href="classbase_client_server.html" title="Support pour la création d&amp;#39;une class client/serveur.">baseClientServer</a>
<a name="l00036"></a>00036 {
<a name="l00037"></a>00037     <span class="keyword">private</span>:
<a name="l00038"></a><a class="code" href="classclient.html#adb571683580a7a0b2dbd6183e52d4dff">00038</a>         <a class="code" href="class___base_client_server_8h.html#a328d951616d1a7f289fef8e6b23a926b">IN_ADDR</a> <a class="code" href="classclient.html#adb571683580a7a0b2dbd6183e52d4dff" title="L&amp;#39;adresse du serveur.">c_serverAdress</a>;<span class="comment">//!&lt; L&#39;adresse du serveur</span>
<a name="l00039"></a>00039 <span class="comment"></span>
<a name="l00040"></a>00040 
<a name="l00041"></a>00041     <span class="keyword">public</span>:
<a name="l00042"></a>00042         <a class="code" href="classclient.html#a4684cdbcdc4a3bd61631d974d0ce3dea" title="Constructeur par défaut.">client</a>();
<a name="l00043"></a>00043         <a class="code" href="classclient.html#ad45e388579b8c0ffec6f29ed2c0c4de9" title="Destructeur par défaut.">~client</a>();
<a name="l00044"></a>00044 
<a name="l00045"></a>00045         <span class="comment">// Accésseurs</span>
<a name="l00046"></a>00046         <span class="keyword">inline</span> <span class="keyword">const</span> <a class="code" href="class___base_client_server_8h.html#a328d951616d1a7f289fef8e6b23a926b">IN_ADDR</a>* <a class="code" href="classclient.html#a7d0ce13ff32457fcff4e85a0348134b1" title="Renvoie le socket utilisé pour la connection avec le serveur.">serverAdress</a>() <span class="keyword">const</span>;
<a name="l00047"></a>00047 
<a name="l00048"></a>00048         <span class="comment">// Modificateurs</span>
<a name="l00049"></a>00049         <span class="keywordtype">void</span> <a class="code" href="classclient.html#a6c40fcab76ed1d882a253a1bf8c33546" title="Permet de définir le serveur où se connecter.">setServerAdress</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> ip[] );
<a name="l00050"></a>00050         <span class="keywordtype">void</span> <a class="code" href="classclient.html#a6c40fcab76ed1d882a253a1bf8c33546" title="Permet de définir le serveur où se connecter.">setServerAdress</a>( <span class="keyword">const</span> <a class="code" href="class___base_client_server_8h.html#a328d951616d1a7f289fef8e6b23a926b">IN_ADDR</a>* ip );
<a name="l00051"></a>00051         <span class="keyword">const</span> <a class="code" href="class___base_client_server_8h.html#a328d951616d1a7f289fef8e6b23a926b">IN_ADDR</a>* <a class="code" href="classclient.html#a70931a97daa1714bf9f36274e5be5c0f" title="Permet de définir le serveur où se connecter.">setServerHost</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> domain[] );
<a name="l00052"></a>00052 
<a name="l00053"></a>00053         <span class="comment">// Autres</span>
<a name="l00054"></a>00054         <span class="keywordtype">bool</span> <a class="code" href="classclient.html#aafb3e1157b7e1f3e81c09fe1c7866a82" title="Permet de se connecter au serveur.">connection</a>();
<a name="l00055"></a>00055         <span class="keywordtype">void</span> <a class="code" href="classclient.html#a8d1188c4d73c355ca3233bd7efbedc75" title="Permet de se déconnecter au serveur.">disconnection</a>();
<a name="l00056"></a>00056         <span class="keywordtype">bool</span> <a class="code" href="classclient.html#a23d55bd91048a867c3c1cb353de27869" title="Permet de savoir si l&amp;#39;on est connecté au serveur.">is_connected</a>();
<a name="l00057"></a>00057 
<a name="l00058"></a>00058         <span class="comment">// Récéption des activités ( Nouvelle connnection, Déconnection, message en attante )</span>
<a name="l00059"></a>00059         <span class="keywordtype">bool</span> <a class="code" href="classclient.html#ae2d32defc7b1e99ef53d599d641a5335" title="Permet de récupérer détecter l&amp;#39;activiter sur le réseau.">lookupConnection</a>();
<a name="l00060"></a>00060 
<a name="l00061"></a>00061         <span class="comment">// Récéption de message</span>
<a name="l00062"></a>00062         <span class="keywordtype">int</span> <a class="code" href="classclient.html#a2ea117a6fd3515343481d4ea4d97eab4" title="Récupère les données envoyées par le serveur.">readServer</a>( <span class="keywordtype">char</span>* buffer, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classbase_client_server.html#afc826d31816db85c53667361e303c37d">bufferSize</a> );
<a name="l00063"></a>00063 
<a name="l00064"></a>00064         <span class="comment">// Envoie de message</span>
<a name="l00065"></a>00065         <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classclient.html#ad37308b8128932bea9ddb5afab3ba441" title="Envoie un message (buffer) au serveur.">send_message</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* buffer, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classbase_client_server.html#afc826d31816db85c53667361e303c37d">bufferSize</a> );
<a name="l00066"></a>00066         <span class="keyword">using</span> baseClientServer::send_message;
<a name="l00067"></a>00067 };
<a name="l00068"></a>00068 
<a name="l00069"></a>00069 <span class="preprocessor">#include &quot;<a class="code" href="class__client_8inl.html">class_client.inl</a>&quot;</span>
<a name="l00070"></a>00070 
<a name="l00071"></a>00071 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Généré le Fri Jan 21 2011 01:21:27 pour Bomberman par&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
